<template>
    <div class="main_box" style="padding:10px">
        <div class="add_wrap">
            <el-form label-width="200px">
                <div class="tit">
                    <h2>基础信息</h2>
                    <el-button type="success" plain size="small" icon="fa fa-mail-forward" @click="returnList">返回
                    </el-button>
                </div>
                <el-row>
                    <el-form-item label="商户:">
                        <span>{{ dataInfo.businessName }}</span>
                    </el-form-item>
                    <el-form-item label="推广规则名称:">
                        <span>{{ dataInfo.ruleName }}</span>
                    </el-form-item>
                    <el-form-item label="推广规则类型:">
                        <span>{{ dataInfo.ruleType == 1 ? '商户' : '平台' }}</span>
                    </el-form-item>
                    <el-form-item label="呼叫器:" v-if="dataInfo.ruleType==2">
                        <span>{{ dataInfo.beeperName }}</span>
                    </el-form-item>
                    <el-form-item label="创建人:">
                        <span>{{ dataInfo.createUserName }}</span>
                    </el-form-item>
                    <el-form-item label="创建时间:">
                        <span>{{ dataInfo.createDate }}</span>
                    </el-form-item>
                    <el-form-item label="修改人:">
                        <span>{{ dataInfo.modifyUserName }}</span>
                    </el-form-item>
                    <el-form-item label="修改时间:">
                        <span>{{ dataInfo.modifyDate }}</span>
                    </el-form-item>
                    <el-form-item label="备注:">
                        <span>{{ dataInfo.remark }}</span>
                    </el-form-item>
                </el-row>
                <div class="tit">
                    <h2>商户推广规则明细</h2>
                </div>
                <el-row style="width:max-content">
                    <el-table style="width:fit-content" :data="list" border highlight-current-row
                        :header-row-style="{ 'background-color': '#f2f2f2' }">
                        <el-table-column label="序号" width="140px" align="center" type="index">

                        </el-table-column>
                        <el-table-column label="产品分类" width="200" align="center">
                            <template slot-scope="scope">
                                <div>
                                    {{ formatServerClassify(scope.row) }}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="goodsId" label="产品编号" width="170px" align="center">

                        </el-table-column>
                        <el-table-column prop="levels" label="产品等级" width="150px" align="center">

                        </el-table-column>
                        <el-table-column prop="firstDiscount" label="首推比例" width="130px" align="center">

                        </el-table-column>
                        <el-table-column prop="secondDiscount" label="次推比例" width="130px" align="center">

                        </el-table-column>

                        <el-table-column prop="thirdDiscount" label="业推比例" width="130px" align="center">

                        </el-table-column>
                        <el-table-column prop="firstMoney" label="首推金额" width="130px" align="center">

                        </el-table-column>
                        <el-table-column prop="secondMoney" label="次推金额" width="130px" align="center">

                        </el-table-column>
                        <el-table-column prop="thirdMoney" label="业推金额" width="130px" align="center">

                        </el-table-column>


                    </el-table>
                </el-row>
            </el-form>
        </div>
    </div>
</template>

<script>
import PromoteRuleApi from '@/api/operation/promoteRule';
export default {
    data() {
        return {
            dataInfo: {},
            list:[]
        };
    },
    computed: {
    },
    mounted() {
        this.getData()
    },
    methods: {
        getData() {
            PromoteRuleApi.getPromoteRule({ id: this.$route.query.id }).then(res => {
                this.dataInfo = res.data
                this.list = res.data.list
            })
        },
        formatServerClassify(row){
            let val = ""
            if(row.parentClassifyId){
                val =row.parentClassifyName
            }
            if(row.serverClassifyId){
                val = val+"-"+row.serverClassifyName
            }

            if(row.thirdClassifyId){
                val = val+"-"+row.thirdClassifyName
            }

            return val
        },
        returnList() {
            this.$store.dispatch('delView', this.$route);
            this.$router.push({ path: '/operation/promoteRuleManagement' })
        }
    },

}

</script>
<style lang="scss" scoped>
@import "@/assets/css/views/add.scss";
</style>
